Skip to content

Fix permission descriptions being cut off - #846

Open
dav1312 wants to merge 1 commit into
zerebos:masterfrom
dav1312:everyone
Open

dav1312 wants to merge 1 commit into
zerebos:masterfrom
dav1312:everyone

Conversation

@dav1312

@dav1312 dav1312 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Fixes permission descriptions (such as "Mention @ everyone") being cut off to the first letter.
image
image

Fixes permission descriptions (such as "Mention @everyone") being cut off to the first letter.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the PermissionSpecification interface to allow description to be a plain string, and updates the getDefinitions function to handle this new type. The reviewer suggests using the nullish coalescing operator (?? "") across the entire ternary expression to guarantee a string is returned, preventing potential undefined values when arrays are empty.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

id: Object.keys(DiscordPermissions).find(key => DiscordPermissions[key as keyof IDiscordPermissions] === perm.flag) ?? "",
name: perm.title,
description: typeof perm.description === "function" ? perm.description(BdApi.Webpack.Stores.LocaleStore.locale).ast[0] : perm.description[0]
description: typeof perm.description === "function" ? perm.description(BdApi.Webpack.Stores.LocaleStore.locale).ast[0] : (Array.isArray(perm.description) ? perm.description[0] : (perm.description || ""))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current fallback logic (perm.description || "") is good, but it doesn't protect against cases where perm.description is a function that returns an empty ast array, or when perm.description is an empty array itself. In those cases, ast[0] or description[0] will be undefined, which violates the PermissionDefinition interface requiring description to be a string. Using the nullish coalescing operator (?? "") at the end of the entire ternary expression ensures that a string is always returned in all scenarios.

Suggested change
description: typeof perm.description === "function" ? perm.description(BdApi.Webpack.Stores.LocaleStore.locale).ast[0] : (Array.isArray(perm.description) ? perm.description[0] : (perm.description || ""))
description: (typeof perm.description === "function" ? perm.description(BdApi.Webpack.Stores.LocaleStore.locale).ast[0] : (Array.isArray(perm.description) ? perm.description[0] : perm.description)) ?? ""

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant